import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { examItemVO, examItemForm, examItemPageResult } from "./types";

/**
 * 获得赛项列表
 *
 * @param queryParams
 */
export function getEventList(
  queryParams?: examItemVO
): AxiosPromise<examItemPageResult> {
  return request({
    url: "/adminApi/match/page",
    method: "get",
    params: queryParams,
  });
}

/**
 * 新增赛项
 *
 * @param data
 */
export function matchCreate(data: examItemVO) {
  return request({
    url: "/adminApi/match/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改赛项
 *
 * @param data
 */
export function matchUpdate(data: examItemVO) {
  return request({
    url: "/adminApi/match/update",
    method: "put",
    data: data,
  });
}

/**
 * 设置试卷
 *
 * @param data
 */
export function setPaper(data: examItemVO) {
  return request({
    url: "/adminApi/match/setPaper",
    method: "put",
    data: data,
  });
}

/**
 * 更新赛项状态
 *
 * @param data
 */
export function updateStatus(data: examItemVO) {
  return request({
    url: "/adminApi/match/updateStatus",
    method: "put",
    data: data,
  });
}

/**
 * 删除赛项
 *
 * @param id
 */
export function matchDelete(id: number) {
  return request({
    url: "/adminApi/match/delete?id=" + id,
    method: "delete",
  });
}

/**
 * 查询赛项的试卷选项
 *
 * @param matchGroup
 */
export function getPaperOptions(matchGroup: number) {
  return request({
    url: "/adminApi/paper/options",
    method: "get",
    params: {
      matchGroup,
    },
  });
}
/**
 * 查询赛项组别
 *
 * @param type 	字典类型：MATCH_GROUP赛项组别,示例值(MATCH_GROUP)
 * @param status 		状态：0未审核，1已审核，null全部,示例值(1)
 */
export function getDictionaryPage(type: string, status: number | string) {
  return request({
    url: "/adminApi/dictionary/page",
    method: "get",
    params: {
      type,
      status,
    },
  });
}
